package com.momo.mal.dashboard;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.momo.mal.Login;
import net.momo.mal.R;
import com.momo.mal.util.ConnectionUtil;

import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.widget.Toast;

import com.viewpagerindicator.IconPagerAdapter;

public class MainActivityAdapter extends FragmentPagerAdapter implements IconPagerAdapter {
	protected static final String[] CONTENT = new String[] { "Profile", "Anime History", "Manga History" };
	protected static final int[] ICONS = new int[] {
		R.drawable.ic_menu_add,
		R.drawable.ic_menu_add,
		R.drawable.ic_menu_add
	};
	
	private int mCount = CONTENT.length;

	public MainActivityAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public int getIconResId(int index) {
		return ICONS[index % ICONS.length];
	}

	@Override
	public Fragment getItem(int position) {
		if(position == 0) {
			return StatisticFragment.newInstance();
		} else if(position == 1) {
			return AnimeFragment.newInstance();
		} else {
			return MangaFragment.newInstance();
		}
	}

	@Override
	public int getCount() {
		return mCount;
	}

	@Override
    public CharSequence getPageTitle(int position) {
		return MainActivityAdapter.CONTENT[position % CONTENT.length];
    }
	
	public void setCount(int count) {
        if (count > 0 && count <= 10) {
            mCount = count;
            notifyDataSetChanged();
        }
    }
	
}
